/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pt.iasd.youthshelter.activity;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import pt.iasd.youthshelter.datamodel.Activity;

/**
 *
 * @author Rui
 */
public class ListSorter {
    /**
     * Sort list of activities by name.
     * @param activities List of activities.
     * @return Sorted list of activities.
     */
    public static List<Activity> sortActivitiesByName(List<Activity> activities) {
        Collections.sort(activities, new Comparator<Activity>() {
            @Override
            public int compare(Activity o1, Activity o2) {
                return o1.getName().compareTo(o1.getName());
            }
        });
        return activities;
    }
    
    /**
     * Sort list of activities by date.
     * @param activities List of activities.
     * @return Sorted list of activities.
     */
    public static List<Activity> sortActivitiesByDate(List<Activity> activities) {
        Collections.sort(activities, new Comparator<Activity>() {
            @Override
            public int compare(Activity o1, Activity o2) {
                return o1.getStartDate().compareTo(o1.getStartDate());
            }
        });
        return activities;
    }
}
